$(function () {
    $.backstretch(
        ["images/login-blurry-bg.jpg","images/bg3.jpg","images/bg4.jpg" ],
        {duration: 3000,
            fade: 750 });
})
layui.use(['form','layer','jquery','zzpUtils'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        zzpUtils = layui.zzpUtils,
        $ = layui.jquery;
    zzpUtils.notification.permission();
    $(".loginBody .seraph").click(function(){
        layer.msg("这只是做个样式，至于功能，你见过哪个后台能这样登录的？还是老老实实的找管理员去注册吧",{
            time:5000
        });
    })

    //登录按钮
    form.on("submit(login)",function(data){
        // $(this).text("登录中...").attr("disabled","disabled").addClass("layui-disabled");
        zzpUtils.action({
            url:"/userLogin/userLogin",
            data:JSON.stringify(data.field),
            success:function (data) {
                if(data.type == "success"){
                    window.location.href = "/zxsdwms/index";
                }else{
                    layer.msg(data.message);
                }
            },error: function (xhr, textStatus) {
                console.log(textStatus);
                console.log(xhr)
            }
        })
        // setTimeout(function(){
        //     window.location.href = "/layuicms2.0";
        // },1000);
        return false;
    })

    //表单输入效果
    $(".loginBody .input-item").click(function(e){
        e.stopPropagation();
        $(this).addClass("layui-input-focus").find(".layui-input").focus();
    })
    $(".loginBody .layui-form-item .layui-input").focus(function(){
        $(this).parent().addClass("layui-input-focus");
    })
    $(".loginBody .layui-form-item .layui-input").blur(function(){
        $(this).parent().removeClass("layui-input-focus");
        if($(this).val() != ''){
            $(this).parent().addClass("layui-input-active");
        }else{
            $(this).parent().removeClass("layui-input-active");
        }
    })
})
